package com.xuecheng.messagesdk.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.xuecheng.messagesdk.model.po.MqMessage;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface MqMessageMapper extends BaseMapper<MqMessage> {
    @Select("select * from mq_message where id % #{shardTotal} = #{shardIndex} " +
            "and message_type = #{messageType} and state = '0' limit #{count}")
    List<MqMessage> getMessageList(@Param("shardIndex") int shardIndex,
                                   @Param("shardTotal") int shardTotal,
                                   @Param("messageType") String messageType,
                                   @Param("count") int count);
}
